package cn.bugstack.springframework.test.bean;

import cn.bugstack.springframework.stereotype.Component;
import cn.bugstack.springframework.util.Autowired;
import cn.bugstack.springframework.util.Value;

import java.util.Random;


@Component("userService")
public class UserService implements IUserService {
    @Value("${token}")
    String token;

    @Autowired
    UserDao userDao;

    public String queryUserInfo() {
        try {
            Thread.sleep(new Random(1).nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
//        return "100001，深圳";
        return userDao.queryUserName("10001")+","+token;
    }

    public String register(String userName) {
        try {
            Thread.sleep(new Random(1).nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "注册用户：" + userName + " success！";
    }

}
